# -*- coding:utf-8 -*-
# @Author : mistchan
# @Time : 2022/5/19 0019 15:54
# @File : myfilter.py
# @Software: PyCharm

from django.template import Library
import os
import decimal

register = Library()


@register.filter(name="path_name")
def path_name(string):
    time_ = os.path.basename(string).split("_")[0]
    date_ = os.path.dirname(string).split(os.sep)[-1]
    # result = f"{date_[:4]}年{date_[4:6]}月{date_[-2:]}日 {time_[:2]}:{time_[2:4]}:{time_[-2:]}"
    result = f"{time_[:2]}:{time_[2:4]}:{time_[-2:]}"

    return result


@register.filter(name="timeit")
def timeit(string1, string2):
    return int(string1) * decimal.Decimal(string2)
